import Hd from "../conent/header_car.js"
import store from "../../store/store";
import {Link} from "react-router"
import Mai from "../conent/main_car.js"

var Guang = React.createClass({
	render : function(){
		return (
			<div className="guang_car" style={this.props.style}>
				<h3>您的购物车空空如也!!!</h3>
				<Link to="home">随便逛逛</Link>
			</div>
		)
	}
})

export default React.createClass({
	getInitialState(){
		return {
			style :{
				display : "block"
			},
			style1:{
				display : "none"
			},
			goodscar:[]
		}
	},
	componentWillMount:function(){
		var ls = store.getState().goodscar.length
		if(ls>0){
			this.setState({
				style:{
					display : "none"
				},
				style1:{
					display : "block"
				},
				goodscar:store.getState().goodscar
			})
		}
	},
	render : function(){
		return (
			<div>
				<Hd/>
				<Guang style={this.state.style}/>
				<Mai data={this.state.style1} list = {this.state.goodscar}/>
			</div>
		)
	}
})
